package Controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;

import Communication.Client;
import Controller.UpdateCustomerController.CustomerInfoListener;
import Controller.HandleNewSaleController;
import DB.CategoryProductQuery;
import DB.CategoryQuery;
import DB.CustomerHistoryQuery;
import DB.CustomerQuery;
import DB.ProductQuery;
import View.UpdateCustomerDeatilsView;
import View.UpdateCustomerHistoryView;
import View.UpdateCustomerView;
/** This class controls and manages the process that allows salesman to update customer history card */
public class UpdateCustomerHistoryController implements Serializable {
	private static final long serialVersionUID = 42L;
	
	/**  Required attributes */
	CustomerHistoryQuery customerHistoryModel;
	static UpdateCustomerHistoryView customerHisView;
	CustomerHistoryListener CustomerHistoryListener;
	Client client;
	
	/**
	 * Constructor calling to listener class that attached to the process
	 * @param client
	 * @param HandleNewSaleController
	 */
	public UpdateCustomerHistoryController(Client client, HandleNewSaleController HandleNewSaleController) {
		this.client = client;
		customerHisView =  new UpdateCustomerHistoryView();
		customerHistoryModel = new CustomerHistoryQuery();
			
	}

	/**  Inner Listener class */ 
	class CustomerHistoryListener implements ActionListener 
	{
		HandleNewSaleController customerHistoryController;
		
		/**
		 * creats Customer History Listener
		 * @param HandleSaleController
		 */
		public CustomerHistoryListener(HandleNewSaleController HandleSaleController) {
			this.customerHistoryController = customerHistoryController;
			//categoryModel = new CategoryQuery();
			//categoryProductModel = new CategoryProductQuery();
			//productModel = new ProductQuery(client);
			customerHisView.showWindow();

		}
		/**
		 * Handle Actions
		 */
		public void actionPerformed(ActionEvent event) {
			System.out.print("yes");
			if (event.getSource() == customerHisView.getBackBtn())
			{  System.out.print("yes");
			customerHistoryController.showWindow();
			customerHisView.showWindow();
		
			}
			else if (event.getSource() == customerHisView.getUpdateBtn()){
				System.out.println("getupdate button");
				}
		}
	}
	/**
	 * function that adds products to the product list to show in combobox
	 * @param products
	 */
	public static void addProducts(String [] products){
		customerHisView.setProducts(products);
	}
}
